#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

class Gloves
{
public:
    int findMinimum(int n, vector<int> left, vector<int> right)
    {
        int lsum = 0, rsum = 0;
        int lmax = INT_MAX, rmax = INT_MAX;
        int ret = 0;
        for (int i = 0; i < n; ++i)
        {
            if (left[i] * right[i] == 0)
            {
                ret += (left[i] + right[i]);
            }
            else
            {
                lsum += left[i];
                rsum += right[i];
                if (left[i] < lmax)
                {
                    lmax = left[i];
                }
                if (right[i] < rmax)
                {
                    rmax = right[i];
                }
            }
        }

        return ret + min(lsum - lmax + 1, rsum - rmax + 1) + 1;
    }
};